Package-level declarations

Contains declarations for manipulating the Result type.

Types

Link copied to clipboard
@SinceKotoolsTypes(version = "4.1")
interface ResultContext

Context available when calling the resultOf function.

Functions

Link copied to clipboard
@ExperimentalSinceKotoolsTypes(version = "4.2")
inline fun <T, R> Result<T>.flatMap(transform: (T) -> Result<R>): Result<R>

Transforms the encapsulated value from T to R if this result is a success, or returns the original exception if this result or the one returned by the transform function is a failure.

Link copied to clipboard
@SinceKotoolsTypes(version = "4.1")
inline fun <T> resultOf(block: ResultContext.() -> T): Result<T>

Returns an encapsulated result of calling the block function in the ResultContext, or returns an encapsulated Throwable if calling the block function throws an exception.